#include "vregistwidget.h"
#include "vswitchinterfacebutton.h"
#include "vlineedit.h"
#include "vpushbutton.h"
#include "verrorpromptlabel.h"

VRegistWidget::VRegistWidget(QWidget* parent)
	: QWidget(parent)
	, m_pButtonSwichBack(new VSwitchInterfaceButton(this))
	, m_pLineEditRegistAccount(new VLineEdit(this))
	, m_pLineEditRegistPassword(new VLineEdit(this))
	, m_pLineEditConfirmPassword(new VLineEdit(this))
	, m_pButtonRegist(new VPushButton(this))
	, m_pLabelErrorPrompt(new VErrorPromptLabel(this))
{
	resize(280, 355);
	move(0, 25);

	initLineEdit();//初始化输入框
	initRegistButton();//初始化按钮
	initConnect();//初始化信号与槽链接

}

VRegistWidget::~VRegistWidget()
{}

void VRegistWidget::initConnect()
{
	connect(m_pLineEditRegistAccount, &VLineEdit::formatError, this, &VRegistWidget::onLineEditAccountFormatError);
	connect(m_pLineEditRegistPassword, &VLineEdit::formatError, this, &VRegistWidget::onLineEditAccountFormatError);
	connect(m_pLineEditConfirmPassword, &VLineEdit::formatError, this, &VRegistWidget::onLineEditAccountFormatError);
}

void VRegistWidget::initRegistButton()
{
	m_pButtonRegist->setText("注册账号");
	m_pButtonSwichBack->move(110, 290);
	m_pButtonSwichBack->setText("返回");
}

void VRegistWidget::initLineEdit()
{
	m_pLineEditRegistAccount->move(30, 31);
	m_pLineEditRegistPassword->move(30, 85);
	m_pLineEditConfirmPassword->move(30, 139);

	m_pLineEditRegistAccount->setPlaceholderText("输入微信账号");
	m_pLineEditRegistPassword->setPlaceholderText("输入微信密码");
	m_pLineEditConfirmPassword->setPlaceholderText("确认微信密码");

	m_pLineEditRegistAccount->setMode(ECHOMODE::REGIST_ACCOUNT);
	m_pLineEditRegistPassword->setMode(ECHOMODE::REGIST_PASSWORD);
	m_pLineEditConfirmPassword->setMode(ECHOMODE::REGIST_PASSWORD);
}


void VRegistWidget::onLineEditAccountFormatError(QSet<ERRORTYPE>errorExist)
{
	m_pLabelErrorPrompt->setErrorPrompt(errorExist);
}